<?php

namespace app\index\controller;

use app\index\logic\Oss;

class Index extends Common
{


    public function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
    }

    public function saveImg($img_path, $img_type, $save_path)
    {
        $oss = new Oss();
        $res = false;
        if (is_array($img_path)) {
            foreach ($img_path as $key => $value) {
                $img_new_path = $save_path . "/" . date('Ymd') . "/" . $this->_makeSerialNumber() . "." . substr($img_type[$key], 6);
                $res = $oss->uploadFile($img_new_path, $value);
            }
        } elseif (is_string($img_path)) {
            $img_new_path = $save_path . "/" . date('Ymd') . "/" . $this->_makeSerialNumber() . "." . substr($img_type, 6);
            $res = $oss->uploadFile($img_new_path, $img_path);
        }

        if ($res)
            return true;
        return false;
    }
}
